package com.example.nonggo.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.nonggo.R;
import com.example.nonggo.utils.ActivityManager;
import com.example.nonggo.view.act.MainActivity;
import com.tencent.mmkv.MMKV;

public class HomeLogoutFragment extends Fragment implements View.OnClickListener {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_home_logout, container);
        view.findViewById(R.id.btn_logout).setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_logout) {
            MMKV.defaultMMKV().clearAll();
            // 关闭当前应用的所有活动
            ActivityManager.finishAll();
            Intent intent = new Intent(getActivity(), MainActivity.class);
            startActivity(intent);

        }

    }
}
